﻿using DWH.PP.LoopUrls.PPMS;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Collections.Generic;
using DWH.Utils;

namespace RDTest
{
    
    
    /// <summary>
    ///This is a test class for PPMSSavePagePicsTaskTest and is intended
    ///to contain all PPMSSavePagePicsTaskTest Unit Tests
    ///</summary>
    [TestClass()]
    public class PPMSSavePagePicsTaskTest
    {


        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion


        /// <summary>
        ///A test for ProcessTargetHtmlContent
        ///</summary>
        [TestMethod()]
        public void ProcessTargetHtmlContentTest()
        {
            PPMSSavePagePicsTask target = new PPMSSavePagePicsTask(); 
            target.Enable = true;
            Guid newId = Guid.NewGuid();
            target.TaskName = "UT for PPMSSavePagePicsTask" + newId.ToString();

            target.ExtendData = new Dictionary<string, string>();
            target.ExtendData[DWHConstants.KEY_CONTENT_PAGE_URL_PATTERN] = @"http://ppmmshow.com/\d+.html$";

            target.ExtendData[DWHConstants.KEY_LOOP_PAGELIST_URL_PATTERN] = "http://ppmmshow.com/category/meinvdoudou/jiepaizipai/page/{0}";
            target.ExtendData[DWHConstants.KEY_LOOP_PAGELIST_NUMBER_START] = "1";
            target.ExtendData[DWHConstants.KEY_LOOP_PAGELIST_NUMBER_END] = "10";
            target.ExtendData[DWHConstants.KEY_WEB_ATTACHMENT_STORE_FOLDER] = "E:/WebPPAttachment/PPMS/";
            target.ExtendData[DWHConstants.KEY_PAGE_TARGET_ELEMENT] = "//a";
            target.ExtendData[DWHConstants.KEY_PAGE_TARGET_ATTRIBUTE] = "href";

            target.ExtendData[DWHConstants.KEY_PAGE_ENCODING] = "utf-8";
            target.ExtendData[DWHConstants.KEY_CONTENT_TARGET_ELEMENT] = "//div[@id]";
            target.ExtendData[DWHConstants.KEY_CONTENT_TARGET_ELEMENT_ATTRIBUTE_NAME] = "id";
            target.ExtendData[DWHConstants.KEY_CONTENT_TARGET_ELEMENT_ATTRIBUTE_VALUE] = @"content";

            target.Initialize();
            target.Run();
        }
    }
}
